Issue The Flash onload method does not
function correctly from within Director. When this
function is executed, it should pass a boolean
(success) value of True or False.
If the file specified by the "load" event
method is missing or the URL is incorrect, no
value will be passed. ( a value (success) of False
should be passed)
Example: XMLObj=newObject("XML")
setCallback(XMLObj, "onLoad", #loadMyXML, 0)
XMLObj.load("http://some incorrect URL")
on loadMyXML me, arg1, success
if success = TRUE then
go to frame 3
put "XML loaded="&success
end if
end loadMyXML
In the example above, the
incorrect URL in the load command should cause the
onLoad to pass 'success' as False. Because this
information is not returned at all, the playhead
will not advance. No testing for a the 'success'
argument can be made.
Reason This is due to a bug in the Flash Asset
Xtra that prevents a "missing file" error from
being forwarded to the Flash XML object.
Therefore, the onLoad callback handler never gets
called if an XML file [being referred to by a
Flash XML load object] is missing. The Director
engineering team is aware of this outstanding bug
and is actively working to resolve it. Please
return to this TechNote for further
updates.
Workaround Use the preLoadNetThing function
to check that the XML file exists prior to running
an ActionScript load event.
PreLoadNetThing will download a file to
the local cache so it can be used later without a
download delay. It also returns a network ID value
that can be used with the Lingo functions
netDone() and netError() to
monitor the progress of the
preLoadNetThing operation.
One issue to consider is that the
netDone() and netError()
functions need to be checked because they do
not broadcast their results. The generally
accepted method used is to check
netDone() and netError() in
consecutive frames following the initial
preLoadNetThing function. Use of
preLoadNetThing is discussed and
demonstrated in the Director Sample movie How
do I use preLoadNetThing ? (TechNote 14595).
The method described in this TechNote
involves creating a small 4 frame Director movie
that will run prior to the main movie. This small
movie will contain a Flash object which checks to
see if the XML file exists. If the file exists and
downloads without an error, then the "main" movie
that hosts the Flash XML object opens. If these is
an error, an error message is
presented. PreLoadNetThing Example
scripts
1 |
Open a new Director MX
movie. |
2 |
Add the following script in Frame two
(2). |
|
global
myNetID on exitFrame set
myNetID=preLoadNetThing("http://myServer.com/myFile.xml") end |
3 |
Add the following script in Frame three
(3). |
|
global
myNetID on exitFrame if netDone(myNetID) =
False then go to the frame end
if end |
4 |
Add the following script in Frame four
(4). This example uses a case statement to check
if an error is returned. In the case that an
error is returned, the appropriate error message
will appear. If the status is OK, the main
movie, "myXMLObjectMovie" opens. For additional
error codes refer to netError() in the
Lingo Dictionary. |
|
global myNetID on
exitFrame
case netError(myNetID)
of "OK": go to movie
"myXMLObjectMovie" 4159: alert "error 4159 -
Invalid URL" 4165: alert "error 4165 -
Requested Object could not be found. The URL may
be incorrect"
end
case end
|
4 |
Test the movie and close Director
MX. |
Additional information
The following Technotes include sample
movies that use onload callback with a
Flash Objects and XML:
XML
Xtra parser memory leak issue (TechNote
16805) Global
Flash command for creating an ActionScript
object (TechNote 16691)
|